<?php
include_once(dirname(__FILE__).'/../public/public_products.php');

class AimersoftProducts extends PublicProducts  {

	var $db, $web_fage;
	function __construct(){
		$this->db = $GLOBALS['db'];
		$this->web_fage = 2;
		parent::__construct( $this->db, $this->web_fage );
	}
	
	/**
	* 返回lion图片地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function lionPicUrl($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];

		$sql = "SELECT lion_url 
				FROM won_product 
				WHERE id = {$id} AND won_product_delete = 0 ";
		$lion_url = $this->db->getOne($sql);
		
		if (!empty($lion_url)) {
			$str = '<img src="'.trim($lion_url).'"  alt="mountain lion" class="lion" />';
		}
		return $str;
		
	}
	
	//note 去品牌产品名称，并加系统
	function productNameNoBrand( $get ){	
		$name = $this->productNameHadOs( $get );
		if( substr(strtolower( $name ), 0, 9) == 'aimersoft' ) $name = substr( $name, 9 );
		return $name;
	}
	

	//note 产品页面url
	function productUrl( $get ){
		$id = $get['产品ID'];
		
		//产品页模板
		$sql = "SELECT url FROM Table_174 WHERE Field_21895 = '{$id}'";
		$url = $this->db->getOne( $sql );

		//产品单页模板
		if( empty($url) ){
			$sql = "SELECT url FROM Table_175 WHERE Field_21901 = '{$id}'";
			$url = $this->db->getOne( $sql );
		}	
			
		$url = str_replace(array('index.html','/aimersoft.com/httpdocs'),array('','http://www.aimersoft.com'),$url);
		return $url;
	}
	
	//note 产品购买url
	function productBuyUrl( $get ){
		
		$id = $get['产品ID'];
		$web_url = isset($get['url']) ? $get['url'] : '';
		
		$sql = "SELECT url FROM Table_176 WHERE Field_21906 = '{$id}'";
		$url = $this->db->getOne($sql);
		
		if( empty( $url ) ){
			$sql = "SELECT url FROM Table_209 WHERE Field_22185 = '{$id}'";
			$url = $this->db->getOne($sql);
		}
		
		if( empty( $url ) ){
			$sql = "SELECT url FROM Table_245 WHERE Field_22306 = '{$id}'";
			$url = $this->db->getOne($sql);
		}
		
		if( $web_url ){
			$url = url_replace($web_url, $url, 'aimersoft');
		}else{
			$url = str_replace(array('index.html','/aimersoft.com/httpdocs'),array('','http://www.aimersoft.com'),$url);
		}	
		return $url;
	}
	
	//note 系统图标
	function sysIcon( $get ){
		$id = $get['产品ID'];
		$row = $this->productInfo( $id );
		$os = $row['product_os'] == 'Win' ? 'win' : 'mac'; 
		
		$str = 'http://images.aimersoft.com/style/images/'.$os.'_icon2.gif';
		return $str;
	}
	
	//note 对应产品系统图标
	function sysIconRel( $get ){
		$id = $get['产品ID'];
		$row = $this->productInfo( $id );
		$os = $row['product_os'] == 'Win' ? 'mac' : 'win'; 
		
		$str = 'http://images.aimersoft.com/style/images/'.$os.'_icon2.gif';
		return $str;
	}
	
	//note 转到对应系统产品页面
	function goRelProductPage( $get ){
		$id = $get['产品ID'];

		$ret = $this->productInfo( $id );	
		if( empty($ret['product_rel']) ) return '';
		
		$sql = "SELECT won.id FROM product AS p
				LEFT JOIN won_product AS won ON won.won_product_id = p.product_id
				WHERE p.product_id = '{$ret['product_rel']}'";
		$row = $this->db->getOneRs( $sql );

		$url = $this->productUrl( array('产品ID'=>$row['id']) );
		
		$str = '<a class="'.($ret['product_os'] == 'Win' ? 'mac' : 'win').'" href="'.$url.'">Go to '.($ret['product_os'] == 'Win' ? 'Mac' : 'Windows').' Version</a>';
		return $str;
	}
	
	//note 对应的win或者mac产品
	function relWinMac( $get ){
		$id = $get['产品ID'];
		
		$ret = $this->productInfo( $id );	
		if( empty($ret['product_rel']) ) return '';
		
		$sql = "SELECT won.id, p.product_name, p.product_os FROM product AS p
				LEFT JOIN won_product AS won ON won.won_product_id = p.product_id
				WHERE p.product_id = '{$ret['product_rel']}'";
		$row = $this->db->getOneRs( $sql );

		$url = $this->productUrl( array('产品ID'=>$row['id']) );
		
		if( $row['product_os'] == 'Win') $row['product_name'] .= ' for Windows';

		$str = '<a class="under_line" href="'.$url.'">Go to '.$row['product_name'] .'</a>';
		$icon = $this->sysIconRel( $get );
		
		$str .= '&nbsp;<img src="'.$icon.'" width="20" />';
		return $str;
	}
	
	/**
	* 产品下载跳转地址
	* @param   array	$get	字段数组
	* @return  string
	*/
	function productDownloadJumpUrl($get) {

		
		$download_url = parent::productDownLoadUrl( $get );
		return $download_url;
//		$sql = "SELECT url FROM Table_196 WHERE Field_22065 = {$id} LIMIT 1 ";
//		$url = $this->db->getOne($sql);
//		
//		if (!empty($url)) {
//		 	return str_replace(array('/aimersoft.com/httpdocs', 'index.html'), array('http://www.aimersoft.com', ''), $url);
//		} else {
//			return '';
//		}	
	}
	
	//note 下载与免费中
	function downloadAndPriceMid( $get ){
		$id = $get['产品ID'];

		$row = parent::productInfo( $id );
		
		$buy_url = $this->productBuyUrl( $get );
		$download_url = parent::productDownLoadUrl( array('产品ID'=>$id) );
		
		$download_jump_url = $download_url;
		
		
		$str = '';
		//免费
		if($row['product_isfree'] == 1){
			$str .= '<a class="download1" rel="nofollow" 
					href="'.$download_jump_url.'"></a>';
		}else{
			//购买
			$str .= '<a href="'.$buy_url.'" class="buy7"></a>';
			
			//试用 
			if($row['product_type'] == 1){
				$str .= '<a href="'.$download_jump_url.'" rel="nofollow" class="free7"></a>';
			}
			//促销
			//if($row['giveaway'] == 1){}
		}

		return $str;
	}
	
	//note 下载与免费下
	function downloadAndPriceBtn( $get ){
		
		$id = $get['产品ID'];

		$row = parent::productInfo( $id );
		
		$buy_url = $this->productBuyUrl( $get );
		$download_url = parent::productDownLoadUrl( array('产品ID'=>$id) );
		
		
		$download_jump_url = $download_url;
		
		
		$str = '';

		//免费
		if($row['product_isfree'] == 1){
			$str .= '<dd><a class="download1" rel="nofollow" 
					href="'.$download_jump_url.'"></a></dd>';
		}else{
			//购买
			$str .= '<dd><a href="'.$buy_url.'" class="buy">Buy '.$row['product_name'].'</a></dd>';
			
			//试用 
			if($row['product_type'] == 1){
				$str .= '<dd><a href="'.$download_jump_url.'" rel="nofollow" class="download">Download '.$row['product_name'].'</a></dd>';
			}
			//促销
			//if($row['giveaway'] == 1){}
		}
		
		return $str;
	}
	
	//note 产品价格
	function productPrice( $get ){
		$id = $get['产品ID'];
		$price = parent::productPrice( $id );
		$str = '<s>'.$price['old'].'</s> <strong>'.$price['curr_int'].'.'.$price['curr_dec'].$price['year'].'</strong>';
		return $str;
	}
	
	//note 产品价格2
	function productPrice_2( $get ){
		$id = $get['产品ID'];
		$price = parent::productPrice( $id );
		$str = '<s>'.$price['old'].'</s> '.$price['curr_int'].'.'.$price['curr_dec'].$price['year'];
		return $str;
	}
	
	//note 右侧bar
	function rightBar( $get ){
		$id = $get['产品ID'];
		
		//判断是否有bar
		$str = '';
		$sql = "SELECT won_product_guide_bar FROM won_product WHERE id = '{$id}'";
		$bar = $this->db->getOne($sql);
		
		if( !empty($bar) ){
			$sql = "SELECT block_title,block_content,block_pic_url,block_pic FROM block
					WHERE FIND_IN_SET(block_id,'{$bar}') AND block_delete = 0";
			$rows = $this->db->getAll( $sql );
			
			$row = $this->productInfo( $id );
			$os = $row['product_os'];
			
			$str = '<div class="title'.($os == 'Win' ? 2 : 6).'"><h2>'.($os == 'Win' ? 'Windows Products' : 'Mac Products').'</h2></div>';
			
			foreach( $rows as $row ){
				$str .= '<div class="title1"><h2>'.$row['block_title'].'</h2></div>
						<div class="bg"><ul class="list1">'.$row['block_content'].'</ul></div>';
			}
			
			$str .= '<div class="btm"></div><div class="blank"></div>';
		}
		return $str;
	}
	
	
	//note 右侧Awards
	function rightAwards( $get ){

		$id = $get['产品ID'];
		$sql = "SELECT awards_image FROM won_product WHERE id = '{$id}'";
		$awards_image = $this->db->getOne($sql);
		
		$str = '';
		if( $awards_image ){
		  $str = '<div class="title3"><h2>Awards</h2></div>
				<div class="bg"><p class="aw"><img src="'.$awards_image.'" width="133" height="82" alt="Awards" /></p></div>
				<div class="btm"></div>
				<div class="blank"></div>';
		}
		
		return $str;
	}
	
	
	//note 右侧tips
	function rightTips( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT tips FROM won_product WHERE id = '{$id}'";
		$tips = $this->db->getOne($sql);
		
		$str = '';
		if( !empty( $tips ) ){
			$str = '<div class="title3"><h2>Guide & Tips</h2></div>
				<div class="bg"><ul class="list1">'.$tips.'</ul></div>
				<div class="btm"></div>
				<div class="blank"></div>';
		}
		return $str;
	}
	
	//note 右侧视频bar
	function rightVideoBar( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT p.product_video_promo,p.video_width,p.video_higth,p.product_id FROM won_product won_p LEFT JOIN product p 
				ON p.product_id = won_p.won_product_id WHERE id = '{$id}'";
		$row = $this->db->getOneRs($sql);
		
		if($row['product_video_promo'] == '') return '';
		
		$str = '<div class="title3"><h2>Watch the Video Demo</h2></div>
				<div class="bg demo videoDemo" href="#video-demo"><a href="javascript:void(0);" class="iframe"><img src="http://images.aimersoft.com/images/video_bg2.png" height="126" width="158" alt="'.$get['产品名称'].' demo" /></a></div>
				<div class="btm"></div>
				<div class="blank"></div>';
		return $str;
	}
	
	//note 右侧视频弹出html
	function rightVideoPopup( $get ){
		$id = $get['产品ID'];
		$video = parent::rightVideoPopup( $id, 'aimersoft' );
		$str = '';
		//$str .= '<link rel="stylesheet" type="text/css" href="http://images.aimersoft.com/scripts/fancybox-2.0.5.css" media="screen" />';
		//$str .= '<script type="text/javascript" src="http://images.aimersoft.com/scripts/fancybox-2.0.5.js?v=2.0.5"></script>';
		$str .= $video;
		return $str;	
	}
	
	
	//note overview描述
	function overveiwDesc( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT overview_desc FROM won_product WHERE id = '{$id}'";
		$str = $this->db->getOne($sql);
		
		return $str ? $str : '';
	}
	
	//note overview图片
	function overveiwImg( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT overview_img FROM won_product WHERE id = '{$id}'";
		$str = $this->db->getOne($sql);
		
		return $str ? '<p><img src="'.$str.'" /></p>' : '';
	}
	
	//note overview附加
	function overveiwAppend( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT overview_append FROM won_product WHERE id = '{$id}'";
		$str = $this->db->getOne($sql);
		
		return $str ? $str : '';
	}
	
	
	//note feature功能点
	function keyFeature( $get ){
		$id = $get['产品ID'];
		
		$str = '';
		$sql = "SELECT f.feature_title,f.feature_intro,f.feature_pic_min,f.feature_pic_max, f.feature_id
				FROM feature f LEFT JOIN won_product won_p ON f.product_id = won_p.won_product_id
				WHERE f.feature_type = 0 AND f.is_delete = 0 AND won_p.id = '{$id}' ORDER BY f.feature_order ASC";
		$result = $this->db->getAll($sql);
		
		foreach( $result as $k=>$v ){			
			$str .= '<div class="feture_box"> <a href="'.$v['feature_pic_max'].'" class="zoom1" title="'.$v['feature_title'].'">
					<img src="'.$v['feature_pic_min'].'" width="180" height="120" class="'.($k%2==0?'l':'r').'_pic" alt="'.$v['feature_title'].'"></a>
         			<h3>'.$v['feature_title'].'</h3>
					<p>'.$v['feature_intro'].'</p>
					<div class="clear"></div>
					</div>';
		}
		return $str;
	}
	
	
	//note feature更多功能点
	function moreFeature( $get ){
		
		$id = $get['产品ID'];

		$sql = "SELECT f.feature_title,f.feature_intro,f.more_feature_pic FROM feature f
				LEFT JOIN won_product won_p ON f.product_id = won_p.won_product_id
				WHERE f.feature_type = 1 AND f.is_delete = 0 AND won_p.id = '{$id}'
				ORDER BY f.feature_order ASC ";
		$rows = $this->db->getAll($sql);
		
		if( empty( $rows ) ) return '';

		$str = '<div class="more_feture"><h3><strong>More Features</strong></h3>';
		foreach( $rows as $k=>$row ){
			$str .= '<div class="feture_list"> <img src="'.$row['more_feature_pic'].'" alt="'.$row['feature_title'].'" width="60" height="60" />
					<h4>'.$row['feature_title'].'</h4>
					<p>'.$row['feature_intro'].'</p>
					</div>';
			if( $k % 2 == 1 ) $str .= '<div class="clear"></div>';
		}
		$str .= '<div class="clear"></div>';
		$str .= '</div>';
		return $str;
	}
	
	
	//note feature其它功能点
	function otherFeature( $get ){
		$id = $get['产品ID'];

		$sql = "SELECT f.feature_title,f.feature_intro,f.more_feature_pic FROM feature f
				LEFT JOIN won_product won_p ON f.product_id = won_p.won_product_id
				WHERE f.feature_type = 2 AND f.is_delete = 0 AND won_p.id = '{$id}'
				ORDER BY f.feature_order ASC ";
		$rows = $this->db->getAll($sql);
		
		if( empty( $rows ) ) return '';

		$str = '<div class="subPro">';
		foreach( $rows as $k=>$row ){
			if( $k > 3 ) break;
			$str .= '<div class="item'.($k==3?' noBor':'').'"> <strong class="title">'.$row['feature_title'].'</strong>
		      <div class="img"><img src="'.$row['more_feature_pic'].'" alt="'.$row['feature_title'].'" width="65" height="65" /></div>
		      <p>'.$row['feature_intro'].'</p>
		    </div>';
		}
		$str .= '</div>';
		return $str;
	}
	
	//note guide页面地址 
	function guideUrl( $get ){
		$id = $get['产品ID'];
		$sql = "SELECT url FROM Table_177 WHERE Field_21914 = '{$id}'";
		$url = $this->db->getOne( $sql );
		$url = url_replace($get['url'], $url ,'aimersoft');
		return $url ? $url : '';
	}
	
	//note Tech页面地址
	function TechUrl( $get ){
		$id = $get['产品ID'];
		$sql = "SELECT url FROM Table_206 WHERE Field_22167 = '{$id}'";
		$url = $this->db->getOne( $sql );
		$url = url_replace($get['url'], $url ,'aimersoft');
		return $url ? $url : '';
	}
	
	//note 产品切换列表
	function switchPage( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT won_attributes_id 
				FROM won_product 
				WHERE id = '{$id}' AND won_product_delete = 0 ";
		$att_str = $this->db->getOne($sql);
		
		$att_str = empty($att_str) ? 0: $att_str;
		
		$sql = "SELECT att.name,att.id,tab.url FROM Table_207 tab 
				LEFT JOIN product_attributes att ON tab.Field_22173 = att.name 
				WHERE tab.Field_22172 = '{$id}' AND FIND_IN_SET(att.id,'".$att_str."') 
				ORDER BY tab.Field_22174 DESC ";
		$rows = $this->db->getAll($sql);
		
		$str = '';
		foreach( $rows AS $row ){
			$url = url_replace($get['url'], $row['url'] ,'aimersoft'); 
			$str .= '<li><a href="'.$url.'">'.trim($row['name']).'</a>|</li>';
		}

		//Reviews
		$sql = "SELECT url FROM Table_186 WHERE Field_21969 = {$id} ";
		$url_reviews = $this->db->getOne($sql);
		
		if (!empty($url_reviews)) {
			$url_reviews = url_replace($get['url'], $url_reviews, 'aimersoft');
			$str .= '<li><a href="'.$url_reviews.'" id="nav_review">Reviews</a></li>';
		}
		return $str; 
	}
	
	//note 切换内容
	function switchContent( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT won_attributes_id FROM won_product WHERE id = {$id}";
		$att_str = $this->db->getOne($sql);	
		
		$page_content = '';
		if( $att_str ){
			$sql = "SELECT page_content FROM product_page WHERE product_id = {$id} AND article_id = (
					SELECT id FROM product_attributes WHERE FIND_IN_SET(id, '{$att_str}') ORDER BY id ASC LIMIT 1
			)";
			$page_content = $this->db->getOne( $sql );
		}
		
		return $page_content ? '<div class="tab_cont">'.$page_content.'</div>' : '';
	}
	
	//note 返回产品页
	function backToProduct( $get ){
		$id = $get['产品ID'];

		$url = $this->productUrl( $get );	
		$row = $this->productInfo( $id );
		$name = $row['product_name'];
		if( substr(strtolower( $name ), 0, 9) == 'aimersoft' ) $name = substr( $name, 9 );
		
		$str = '<a href="'.$url.'">
				<img align="absmiddle" border="0" src="http://images.aimersoft.com/style/images/icon_dot.png"> Back to '.$name.'</a>';
		return $str;
	}
	
	
	//note 图片广告
	function imgAd( $get ){	
	}
	
	
	//note 推荐产品
	function recProduct( $get ){
	}

	
	//note 推荐购买产品
	function recStoreProduct( $get ){
		
		$product_os = $get['产品类型'] == 1 ? 'Win' : 'Mac'; 

		$sql = "SELECT won.`id`,p.`product_id`,p.`product_name`,p.`product_box_big`,p.`product_intro` FROM `won_product` AS won
				LEFT JOIN `product` AS p ON won.won_product_id = p.product_id
				WHERE p.`product_os` = '{$product_os}' AND won.`web_type` = 2 AND won.`won_product_delete`= 0 AND won.`tag` LIKE '%Top Seller%' limit 0,4";
		$rows = $this->db->getAll( $sql );
		
		$str = '';
	
		foreach( $rows as $v ){
			$arr = array('产品ID'=>$v['id']);
			$url = $this->productUrl( $arr );		
			$buy_url = $this->productBuyUrl( $arr );

			$price = parent::productPrice( $v['id'] );
			
			if( substr(strtolower( $v['product_name'] ), 0, 9) == 'aimersoft' ) $v['product_name'] = substr( $v['product_name'], 9 );
			
			$str .= '<div class="pro_box7">
				<h2><a href="'.$url.'">'.$v['product_name'].'</a></h2>
				<a href="'.$url.'"><img src="'.$v['product_box_big'].'" alt="'.$v['product_name'].'" width="120" height="150" /></a>
				<p class="money3">Only <strong>'.$price['curr_int'].'.'.$price['curr_dec'].$price['year'].'</strong> <span class="price text_line">'.$price['old'].'</span></p>
				<p class="btn"><a href="'.$buy_url.'" class="buy4">Buy Now</a></p>
				</div>';
		}

		return $str;
	}
	
	
	//note 产品购买分类列表
	function productStoreCatList( $get ){
		$product_os = $get['产品类型'] == 1 ? 'Win' : 'Mac'; 

		$sql = "SELECT `cat_id`,`cat_title`, `cat_image` FROM `category` 
				WHERE `cat_web` = 2 AND `cat_type` = 2 AND `cat_series` = 3 AND `is_delete` = 0 and `cat_id` in
		 		(SELECT cat_id FROM won_product AS won
				LEFT JOIN product AS p ON won.`won_product_id` = p.`product_id`
				WHERE p.product_os = '{$product_os}' AND p.`product_delete` = 0 AND won.`web_type` = 2 AND won.`won_product_delete` = 0
				GROUP BY won.cat_id) ORDER BY sort_order ASC";
		$rows = $this->db->getAll( $sql );
	
		$str = '';
		foreach( $rows as $v ){
			$str .= '<div class="title"> <img src="'.$v['cat_image'].'" width="40" height="40" /><h2>'.$v['cat_title'].'</h2></div>';
			
			$sql = "SELECT won.`id`, p.`product_id`, p.`product_name`, p.`product_box_middle`, p.`product_intro` FROM `won_product` AS won
					LEFT JOIN `product` AS p ON won.won_product_id = p.product_id
					WHERE p.`product_os` = '{$product_os}' AND won.`web_type` = 2 AND won.`won_product_delete` = 0 AND won.`cat_id` = '{$v['cat_id']}'";
			$data = $this->db->getAll( $sql );
			
			$i = 1;
			foreach( $data as $k=>$d ){
				$arr = array('产品ID'=>$d['id']);
				$buy_url = $this->productBuyUrl( $arr );
				if(empty( $buy_url )) continue;
				
				$url = $this->productUrl( $arr );
				$price = parent::productPrice( $d['id'] );
				
				$bg = 'nobg';
				if( isset($data[$k+1]) && ($i % 3 != 0) ) $bg = '';
				
				$str .= '<div class="item9 fl '.$bg.'"><a href="'.$url.'"><img src="'.$d['product_box_middle'].'" alt="'.$d['product_name'].'"></a>
					<div class="text">
					<h3><a href="'.$url.'">'.$d['product_name'].'</a></h3>
					<p>'.$d['product_intro'].'</p>
					<p><a href="'.$buy_url.'" class="buy3">Buy Now</a><span class="money5"><strong>'.$price['curr_int'].'.'.$price['curr_dec'].$price['year'].'</strong></span></p>
					<div class="clear"></div>
					</div></div>';
				if( $i % 3 == 0 ) $str .= '<div class="clearer"></div>';
				$i++;
			}
			$str .= '<div class="clearer"></div><br /><br />';
		}
		
		return $str;
	}
	
	
	//note 推荐下载产品
	function recDownloadProduct( $get ){
		
		$wonid = (int) $get['产品ID'];
		$product_os = $get['产品类型'] == 1 ? 'Win' : 'Mac'; 

		$sql = "SELECT won.`id`, won.`top_image`, p.`product_id`, p.`product_name`, p.`product_intro` FROM `won_product` AS won
				LEFT JOIN `product` AS p ON won.won_product_id = p.product_id
				WHERE p.`product_os` = '{$product_os}' AND won.`web_type` = 2 AND won.`won_product_delete`= 0 AND won.`tag` LIKE '%Top Downloader%' ORDER BY won.`id` DESC limit 0,2";
		$rows = $this->db->getAll( $sql );
		
		$str = '';
		foreach( $rows as $k=>$v ){
			$arr = array('产品ID'=>$v['id']);
			$url = $this->productUrl( $arr );
			$buy_url = $this->productBuyUrl( $arr );
			
			$download_url = parent::productDownLoadUrl( $arr );
			$get['产品ID'] = $v['id'];
		
			$download_jump_url = $download_url;
			
			
			$price = parent::productPrice( $v['id'] );
			
			$str .= '<div class="pro_box '.($k==0?'fl':'fr').'">
					<div class="tab_cont">
					<p class="pic"><a href="'.$url.'"><img src="'.$v['top_image'].'" alt="'.$v['product_name'].'" width="336" height="140" /></a></p>
					<p><a href="'.$url.'"><strong>'.$v['product_name'].'</strong></a> '.$v['product_intro'].'</p>
					<br />
     				<p class="fr"><span class="money">Price: <strong>'.$price['curr_int'].'.'.$price['curr_dec'].$price['year'].'</strong> <s>'.$price['old'].'</s></span>
     				<a href="'.$buy_url .'" class="buy1">Buy Now</a>
     				<a href="'.$download_jump_url.'" rel="nofollow" class="free1">Free Trial</a></p>
					<div class="clear"></div>
					</div>
					</div>';
		}
		$get['产品ID'] = $wonid;
		return $str;	
	}
	
	
	//note 产品下载分类列表
	function productDownloadCatList( $get ){
		
		$wonid = (int) $get['产品ID'];
		$product_os = $get['产品类型'] == 1 ? 'Win' : 'Mac'; 

		$sql = "SELECT `cat_id`,`cat_title`, `cat_image` FROM `category` 
				WHERE `cat_web` = 2 AND `cat_type` = 2 AND `cat_series` = 3 AND `is_delete` = 0 and `cat_id` in
		 		(SELECT cat_id FROM won_product AS won
				LEFT JOIN product AS p ON won.`won_product_id` = p.`product_id`
				WHERE p.product_os = '{$product_os}' AND p.`product_delete` = 0 AND won.`web_type` = 2 AND won.`won_product_delete` = 0
				GROUP BY won.cat_id) ORDER BY sort_order ASC";
		$rows = $this->db->getAll( $sql );
		
		$str = '';
		foreach( $rows as $v ){
			$str .= '<div class="title"> <img src="'.$v['cat_image'].'" width="40" height="40" /><h2>'.$v['cat_title'].'</h2></div>';
			$str .= '<div class="item6">';
			$str .= '<table cellpadding="0" cellspacing="0"  class="tab1">
			           <tr>
			            <th width="280" align="left">Product</th>
			            <th width="107" >Download</th>
			            <th width="82" >Size</th>
			            <th width="280" align="left">Product</th>
			            <th width="107" >Download</th>
			            <th width="82" >Size</th>
			          </tr>
					</table>';
			
			$sql = "SELECT won.`id`, p.`product_id`, p.`product_name`, p.`product_box_middle`, p.`product_intro`, p.`product_icon_min` FROM `won_product` AS won
					LEFT JOIN `product` AS p ON won.won_product_id = p.product_id
					WHERE p.`product_os` = '{$product_os}' AND won.`web_type` = 2 AND won.`won_product_delete` = 0 AND won.`cat_id` = '{$v['cat_id']}'";
			$data = $this->db->getAll( $sql );
			
			$i = 0;
			foreach( $data as $k=>$d ){
				$arr = array('产品ID'=>$d['id']);
				
				$download_url = parent::productDownLoadUrl( $arr );
				
				$get['产品ID'] = $d['id'];
				
				$download_jump_url = $download_url;
				
				
				if(empty( $download_url )) continue;
				
				$url = $this->productUrl( $arr );
				if(empty( $url )) continue;
				
				$size = parent::proudctSize( $arr );
				
				$s = (($k + 1)%2 == 0 || !isset( $data[$k+1] )) ? 'r' : 'l';
				
				$i++;
				if( $i == 3 || $i == 4 ) $b = 'bg_clr';else $b = '';
				if( $i == 4 ) $i = 0;	
				
				if( substr(strtolower( $d['product_name'] ), 0, 9) == 'aimersoft' ) $d['product_name'] = substr( $d['product_name'], 9 );
	
				$str .= '<ul class="pro_list_'.$s.' '.$b.'">
						<li class="list_icon"><img src="'.$d['product_icon_min'].'" width="32" height="32" /></li>
						<li class="list_pro"><a href="'.$url.'"><strong>'.$d['product_name'].'</strong></a><br />
							<span class="gray">'.$d['product_intro'].'</span></li>
						<li class="list_free"><a href="'.$download_jump_url.'" rel="nofollow" class="free2">Free Trial</a>
						</li>
						<li class="list_size">'.$size.'MB</li>
						</ul>';
			}
			
			$get['产品ID'] = $wonid;
			
			$str .= ' <div class="clear"></div></div><br /><br />';
			
		}
		return $str;
	}
	
	
	//note 评论信息
	function reviews( $get ) {
		$id = $get['产品ID'];
		
		$sql = "SELECT url FROM Table_186 WHERE Field_21969 = '{$id}'";
		$url_reviews = $this->db->getOne($sql);
		
		if( empty($url_reviews) ) {
			return '';
		}

		$url_reviews = url_replace($get['url'],$url_reviews ,'aimersoft');
		
		$str = parent::reviews( $id, $url_reviews );
		return $str;
	}
	
	//note 写评论地址
	function reviewsWriteUrl($get) {
		$id = $get['产品ID'];
		$product_brand = $this->productBrand($get);
		
		$str = 'http://www.aimersoft.com/reviews/reviews-write.html';
		$str .= '?pid='.$id;
		$str .= '&p='.$product_brand;
		
		$row = parent::productInfo( $id );
		
		$str .= '&n='.urlencode($row['product_name']);
		
		if ( $row['product_os'] == 'Win' ) {
			$str .= '&os=Windows';
		} else if($row['product_os'] == 'Mac' ) {
			$str .= '&os=Mac';
		}
		
		return $str;	
	}
	
	
	/**
	* 下载跳转步骤
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function downloadJumpSteps($get) {

		$str = '';
		if ($get['选择类型'] == 1 ) { //代表为Win类型
			
			$str = '<div class="box1">
					<div class="item">
					<span class="num">1.</span>
					<p>Depending on your connection speed, the download may take up to a few minutes.</p>
					<img src="http://images.aimersoft.com/images/download-switch/win-1.png">
					</div>
					<div class="item">
					<span class="num">2.</span>
					<p>The Product setup wizard will be launched.</p>
					<img src="http://images.aimersoft.com/images/download-switch/win-2.jpg">
					</div>
					<div class="item">
					<span class="num">3.</span>
					<p>Double-click the software icon to open the application.</p>
					<img src="http://images.aimersoft.com/images/download-switch/win-3.jpg">
					</div>
					</div>';
			
		} else if($get['选择类型'] == 2) {//代表为Mac类型
			
			$str = '<div class="box1">
					<div class="item">
					<span class="num">1.</span>
					<p>Double-click the .DMG file to open it up and a Finder window will appear.</p>
					<img src="http://images.aimersoft.com/images/download-switch/mac-1.jpg">
					</div>
					<div class="item">
					<span class="num">2.</span>
					<p>Drag and drop the Application icon into your "Applications" directory.</p>
					<img src="http://images.aimersoft.com/images/download-switch/mac-2.jpg">
					</div>
					<div class="item">
					<span class="num">3.</span>
					<p>Double-click the software icon to open the application.</p>
					<img src="http://images.aimersoft.com/images/download-switch/mac-3.jpg">
					</div>
					</div>';
		}

		return $str;
	}
	
	/**
	* 最后一条产品评论以及作者
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productLastReviews($get) {

		$str = '';
		
		$rows = parent::productLastReviewsInfo($get);
		
		if (!empty($rows)) {
			
			$str = '<div class="info"><strong>'.$get['产品名称'].' users review </strong>
            <div class="img"><img src="http://images.aimersoft.com/style/images/good_03.png" /></div>';
			$str .= '<p>'.$rows['review'].'</p><span class="fr">————'.$rows['username'].'</span></div>';
		}
		
		return $str;
	}
	
	/**
	* 产品价格前台显示
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productPriceShow($get) {

		$str = '';
		$arr = parent::productPriceOldAndCurr($get);//得到价格信息
	
		$str = '<strong class="price">'.$arr['curr'].'</strong> <del>'.$arr['old'].' </del>' ;
		return $str;	
	}
	
	
	
	/**
	* 绑定相关产品
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function bindingRelatedProduct($get) {

		$str = '';
		$wonid = (int) $get['产品ID'];
		$result = parent::bindingRelatedProductInfo($get);
		if (empty($result)) {
			return '';
		}
		
		$i = 0;
		while ($row = $this->db->fetch_array($result)) {
			
			if ($row['product_type'] == 1) { //是否试用
				
				
				$product_url = $this->productUrl($get);//得到产品url
				$get['产品ID'] = $row['id'];
				$download_url = parent::productDownLoadUrl($get);//得到产品下载链接
				
				$download_jump_url = $download_url;
				
				
		
				if ($i != 0 ){
					$str .= '<div class="item">';
				}
				$str .=  
				'<div class="img"><a href="'.$product_url.'"><img src="'.$row['product_box_middle'].'" width="100px;" height="100px;"/></a></div>
                <h3><a href="'.$product_url.'">'.$row['product_name'].'</a></h3>
                <p>'.$row['product_intro'].'</p>
                <a href="'.$download_jump_url.'" class="free1" target="_blank" >Free Trial</a>
            	</div>';
				$i = $i + 1;
			}
		}
		
		$get['产品ID'] = $wonid;
		
		$str_before = ' <h2>Customers who liked '.$get['产品名称'].', also bought:</h2> <div class="box3">';
		
		if( $i > 1) {
			$str = $str_before.'<div class="item borR">'.$str.'</div>';
		} else if($i == 1) {
			$str = $str_before.'<div class="item">'.$str.'</div>';
		}else {
			return '';
		}
		
		unset($row);
		return $str;
	}
	
	/**
	* 得到评论列表和分页信息 
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function reviewsCreatePage($get = array() ) {
		
		$id = $get['产品ID'];
		
		$DirName = dirname($get['url']);
		$dirurl = str_replace('/aimersoft.com/httpdocs/','',$DirName);
		//不预览
		$template_str = $this->replaceTemplateAndGet($get['tem_style']);
		$get['do'] = isset($get['do']) ? $get['do'] : '';
		if ( $get['do'] != 'view') {
			
			$dir = DOC_ROOT.'/'.$DirName;
			MakeDir1($dir);
			
			if (!is_dir($dir)) {
				$DirName = DOC_ROOT.'/aimersoft.com/httpdocs';
			}
		}
		
		$sql = "SELECT * FROM product_reviews_detail WHERE pid = '{$id}' AND check_state = 1 ORDER BY `date` DESC";
		$all = $this->db->getAll($sql);
		
		/************************* 全部 ********************************************/
		$total = count($all);
		$max_page = ceil($total / 10);
		for ($i = 1; $i <= $max_page; $i++) {
		
			$temp = $template_str;
			$page_start = ($i - 1) * 10 + 1;
			$page_end = ($i - 1) * 10 + 10;
			
			if( $page_end >= $total) {
				$page_end = $total;
			}
			
			$list = '';
			$chang_sum = 0;
			for ($j = ($i - 1)* 10; $j <= $i * 10 - 1; $j++) {
				
				if ($j >= $total) {
					break; 	
				}  
			
				$list .= '<div class="reviewsItem">
				<div  class="rating">
				<ul>
				<li '.($all[$j]['star'] >= 1 ? 'class="on"' : '').'><a href="javascript:;">1</a></li>
				<li '.($all[$j]['star'] >= 2 ? 'class="on"' : '').'><a href="javascript:;">2</a></li>
				<li '.($all[$j]['star'] >= 3 ? 'class="on"' : '').'><a href="javascript:;">3</a></li>
				<li '.($all[$j]['star'] >= 4 ? 'class="on"' : '').'><a href="javascript:;">4</a></li>
				<li '.($all[$j]['star'] >= 5 ? 'class="on"' : '').'><a href="javascript:;">5</a></li>
				</ul>
				</div>
				<strong class="title">'.str_replace('\\','',$all[$j]['title']).'</strong><br/>
				<span class="info">'.$all[$j]['username'].' | '.$all[$j]['date'].'</span>
				<div class="clear"></div>
				
				<p class="con">'.str_replace(array("\\","\r\n"),array('','<br/>'),$all[$j]['review']).'</p>
				
				<div class="ud"><a href="javascript:s_o('.$all[$j]['did'].',1);" class="up"></a>
					<span class="fl" id="support_'.$all[$j]['did'].'">'.$all[$j]['support'].'</span><a href="javascript:s_o('.$all[$j]['did'].',2);" class="down"></a>
					<span class="fl" id="oppose_'.$all[$j]['did'].'">'.$all[$j]['oppose'].'</span></div>
				<div class="addthis_toolbox addthis_default_style share fr"> 
				<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a></div>';
				
				if( !empty($all[$j]['reply']) ) {
					$list .= '<div class="clear"></div><p class="reply"><strong>Aimersoft:</strong><br />'.$all[$j]['reply'].'</p>';
				}
				
				$list .= '<div class="btm"></div></div>';
			}
		
			//分页
			$page = '<div class="paging">';
			if ( $i  > 1 ) {
				if($i -1 == 1){
				$page .= '<a href="'.'../../'.$dirurl.'/" class="prev">Prev</a>';
				}else{
					$page .= '<a href="'.'../../'.$dirurl.'/'.($i-1).'.html" class="prev">Prev</a>';
				}
			} else {
				$page .= '<a class="prev">Prev</a>';
			}
		
		
			$start = $i - 4;
			$end = $i + 4;
			if ($start < 1) {
				$start = 1; $end = 6;
			}
			
			if ($end > $max_page) {
				$end = $max_page; $start = $max_page - 5;
			}
			
			if ($start < 1) {
				$start = 1;
			}
			
			if ($start != 1) {
				$output .= '';	
			}
			
			for ($start; $start <= $end; $start++) {
				
				if ($i == $start) 
				{
					$page .= '<strong>'.$start.'</strong>';
				} else {
					if ($start == 1) {
						$page .= '<a href="'.'../../'.$dirurl.'/">'.$start.'</a>';
					} else {
						$page .= '<a href="'.'../../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
					}
				}
			}
			
			if ($end != $max_page) {
				$output .= '';
			}
			if ($i < $max_page) {
				$page .= '<a href="'.'../../'.$dirurl.'/'.($i+1).'.html" class="next">Next</a>';
			} else  {
				$page .= '<a class="next">Next</a>';
			}
		
			if ( $total == 0 ) {
				$page = '<div class="paging">';	
			} 
		
			$page = $list.$page.'</div>';

			if (isset($get['do']) && $get['do'] == 'view') {
				return $page;
			}
			
			$temp = str_replace("<!--page_module-->", $page, $temp);
			$temp = str_replace('$'.'{评论列表和分页信息}', '', $temp);
			$temp = str_replace('$'.'{页面关键字生成}', $this->titleCreate($get), $temp);
			$temp = str_replace('$'.'{页面描述生成}', $this->descriptionCreate($get), $temp);
			$temp = str_replace('$'.'{页面title生成}', $this->titleCreate($get).' of '.$i, $temp);
			$temp = str_replace('$'.'{产品父类}', $this->parentCat($get),$temp);
			$temp = str_replace('$'.'{产品名称}', $get['产品名称'],$temp);
			$temp = str_replace('$'.'{转到对应系统产品}', $this->goRelProductPage($get), $temp);
			$temp = str_replace('$'.'{去品牌产品名称}', $this->productNameNoBrand($get), $temp);
			$temp = str_replace('$'.'{评论信息}', $this->reviews($get), $temp);
			$temp = str_replace('$'.'{写评论地址}', $this->reviewsWriteUrl($get), $temp);
			$temp = str_replace('$'.'{产品页面地址}', $this->productUrl($get), $temp);
			$temp = str_replace('$'.'{右侧bar}', $this->rightBar($get), $temp);
			$temp = str_replace('$'.'{右侧视频bar}', $this->rightVideoBar($get), $temp);
			$temp = str_replace('$'.'{右侧Awards}', $this->rightAwards($get), $temp);
			$temp = str_replace('$'.'{右侧tips}', $this->rightTips($get), $temp);
			$temp = str_replace('$'.'{右侧视频弹出html}', $this->rightVideoPopup($get), $temp);
			$temp = str_replace('$'.'{下载与免费下}', $this->downloadAndPriceBtn($get), $temp);
			$temp = str_replace('$'.'{产品切换列表}', $this->switchPage($get), $temp);
			$temp = str_replace('$'.'{视频或其它}', $this->videoOrOther($get), $temp);
			$temp = str_replace('$'.'{右侧留言}', $this->rightWord($get), $temp);
			$temp = str_replace('$'.'{底部推荐产品}', $this->btnRecProduct($get), $temp);
			
			$temp = str_replace('$'.'{产品下载跳转地址}', $this->productDownloadJumpUrl($get), $temp);
			$temp = str_replace('$'.'{产品购买地址}', $this->productBuyUrl($get), $temp);
			$temp = str_replace('$'.'{guide页面地址}', $this->guideUrl($get), $temp);
			$temp = str_replace('$'.'{Tech页面地址}', $this->TechUrl($get), $temp);
		
			$temp = str_replace('$'.'{导航高亮}', $this->navHeightLight($get), $temp);
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
			
			$str_link  = '';
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == 1 ) {
			
				$str_link = '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i > 1 && $i < $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				
				$str_link .= '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == $max_page) {
				
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			}
			
			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			}else{
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}
		}
	}
	
	
	
	//note 产品父类
	function parentCat( $get ){
		$id = $get['产品ID'];
		$sql = "SELECT cat_id FROM won_product WHERE id = '{$id}'";	
		$cat_id  = $this->db->getOne( $sql );
		
		$str = '';
		switch( $cat_id  ){
			case 356:
				$str = '<a href="http://www.aimersoft.com/dvd-software-mac.html">DVD Tools for Mac</a>';
			break;
			case 353:
				$str = '<a href="http://www.aimersoft.com/dvd-software.html">DVD Tools for Windows</a>';
			break;
			case 355:
				$str = '<a href="http://www.aimersoft.com/video-software-mac.html">Video Tools for Mac</a>';
			break;
			case 352:
				$str = '<a href="http://www.aimersoft.com/video-software.html">Video Tools for Windows</a>';
			break;
			case 354:
				$str = '<a href="http://www.aimersoft.com/pdf-software.html">PDF Tools for Windows</a>';
			break;	
		}
		return $str;	
	}
	
	//note 导航高亮
	function navHeightLight( $get ){
		$str = $this->parentCat( $get );
		
		$nav = '';
		if( strpos( $str, 'dvd' ) ){
			$nav = 'dvd';
		}elseif( strpos( $str, 'video' ) ){
			$nav = 'video';
		}elseif( strpos( $str, 'pdf' ) ){
			$nav = 'pdf';
		}
		
		$str = '$("#nav > ul > li").currentMenu({text: "'.$nav.'", style: "curr"});';
		return $str;
	}
	
	/**
	* 返回页面当前地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function currentUrl( $get ){
		$url = str_replace(array('index.html','/aimersoft.com/httpdocs/'),array('','http://www.aimersoft.com/'),$get['url']);
		return $url;
	}
	
	
	//note 底部推荐产品
	function btnRecProduct( $get ){
		$id = $get['产品ID'];
		$sql = "SELECT recommended_product FROM won_product WHERE id = '{$id}'";	
		$row = $this->db->getOne( $sql );
		
		if( empty($row) ) return '';
		$arr = explode(',', $row);
		
		$str = '<div class="break"></div>
				<div class="main">
				<div class="more_feture ml15 recommend">
				<h3><strong>You May Be Interested in These Items</strong></h3>';
		foreach( $arr as $k=>$v ){
			if( $k>2) break;
			$sql = "SELECT won.`id`, p.`product_id`, p.`product_name`, p.`product_box_middle`, p.`product_content` FROM `won_product` AS won
					LEFT JOIN `product` AS p ON won.won_product_id = p.product_id
					WHERE won.id = '{$v}'";
			$p = $this->db->getOneRs( $sql );
			
			$p_url = $this->productUrl( array('产品ID'=>$v) );
			$buy_url = $this->productBuyUrl( array('产品ID'=>$v,'url'=>$get['url']) );
			$jump_url = parent::productDownLoadUrl(array('产品ID'=>$v));//得到产品下载链接
//			$jump_url = $this->productDownloadJumpUrl( array('产品ID'=>$v) );
			$price = parent::productPrice( $v );
			
			$str .= '<div class="item">
				      <div class="img"><a href="'.$p_url.'"><img src="'.$p['product_box_middle'].'" alt="'.$p['product_name'].'"/></a>
				        <div class="price" align="center">'.$price['curr_int'].'.'.$price['curr_dec'].$price['year'].'</div>
				      </div>
				      <span>Aimersoft</span>
				      <h4><a href="'.$p_url.'">'.(substr(strtolower( $p['product_name'] ), 0, 9) == 'aimersoft' ? substr( $p['product_name'], 9 ) : $p['product_name']).'</a></h4>
				      <p class="mb10">'.$p['product_content'].'</p>
				      <a href="'.$buy_url.'" class="buy_min"></a><a href="'.$jump_url.'" class="free_min" rel="nofollow"></a>
				    </div>';
		}

		$str .= '</div></div>';
		return $str;
	}
	
	
	//note 视频或其它
	function videoOrOther( $get ){
		$str = $this->rightVideoBar( $get );
		if( !empty( $str) ) return $str;
		
		return $this->smallPopBigImg( $get );
	}
	
	
	//note 小图弹大图
	function smallPopBigImg( $get ){
		$id = $get['产品ID'];
		
		$sql = "SELECT overview_img, screenshots FROM won_product WHERE id = '{$id}'";
		$row = $this->db->getOneRs($sql);
		
		if( empty( $row ) ) return '';

		$str = '<div class="title3">
		      <h2>Screenshots</h2>
		    </div>
		    <div class="bg list1" align="center"><a class="zoom" href="'.$row['overview_img'].'"><img src="'.$row['screenshots'].'" /></a></div>
		    <div class="btm"></div>
		    <div class="blank"></div>';
		return $str;
	}
	
	
	//note 右侧留言
	function rightWord( $get ){
		$id = $get['产品ID'];
		$sql = "SELECT review AS content, username AS user, date FROM product_reviews_detail 
				WHERE pid = '{$id}' AND is_rec = 1";
		$row = $this->db->getOneRs( $sql );
		
		if( empty( $row ) ) return '';
		
		$sql = "SELECT url FROM Table_186 WHERE Field_21969 = {$id}";
		$url_reviews = $this->db->getOne($sql);
		$url_reviews = url_replace($get['url'] ,$url_reviews, 'aimersoft');
		
		$str = '<div class="title3"><h2>User Review</h2></div>
			    <div class="bg comment">
			      <p>"'.$row['content'].'"</p>
			      <p align="right"> - '.$row['user'].'</p>
					<a href="'.$url_reviews.'" class="fr mt15">More Reviews &gt;&gt;</a></div>
			    <div class="btm"></div>
			    <div class="blank"></div>';
		return $str;
	}
	
	
	//note whatsnew内容
	function whatsnewContent( $get ){
		$id = $get['产品ID'];
		$p = $this->productInfo( $id );
		
		if( empty($p) ) return '';
		
		$product_id = $p['product_id'];
		
		$sql = "SELECT whatisnew_content FROM version WHERE product_id = '{$product_id}' AND is_sale = 1";
		$row = $this->db->getOne( $sql );
		
		return $row ? str_replace("\r\n", '<br/>', $row) : '';
	}
	/**
	 * 返回产品页面固定栏 
	 * @param   array      		 $get       字段数组
	 * @return  string
	 */
	function product_fixed($get) {
		$id = ( int ) $get ['产品ID'];
		$buttondown = $buttonfree = $buttonbuy = '';
		$downUrl = parent::productDownLoadUrl( $get );
		$buyUrl = $this->productBuyUrl( $get );
		$productNameOS = parent::productNameHadOs( $get );
		$guidUrl = $this->guideUrl( $get );
		$TechUrl = $this->TechUrl( $get );
		$sql = "SELECT p.product_type,p.product_isfree 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0  ";
		$productRs = $this->db->getOneRS ( $sql );
		
		if($productRs['product_isfree']==1){
			$buttondown = '<a href="' . $downUrl . '" class="downBtn2 fr mr10">Download</a>';

			
		} else {
			if ($productRs['product_type'] == 1) {
				$buttonfree = '<a href="' . $downUrl . '" class="downBtn2 fr mr10" >Free Trial</a>';
				 $buttonbuy = '<a href="' . $buyUrl . '"  class="buyBtn2 fr mr10" >Buy Now</a>';
				
			} else {
				$buttonbuy = '<a href="' . $buyUrl . '"  class="buyBtn2 fr mr10" >Buy Now</a>';
			}
		}
		
		$switch = $this->switchPage ( $get );
		$str='<div id="topBar" style="display:none;">
  		<div class="wrap"> '. $buttonbuy.$buttonfree.$buttondown.'
    		<ul class="nav fl ">
      			<li><a href="'.$guidUrl.'">Guide</a>|</li>
      			<li><a href="'.$TechUrl.'">Tech Spec</a>|</li>
     			 '.$switch.'
    		</ul>
      	</div>
		</div>';
		return $str;
	}	
}